<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/extras/spring-security5">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>admin</title>
    <link rel="stylesheet" th:href="@{/webjars/bootstrap/5.1.3/css/bootstrap.css}">
    <script th:src="@{/webjars/bootstrap/5.1.3/js/bootstrap.js}"></script>
</head>
</head>
<body class="text-center">

<div class="container mt-3">
    <h2>admin</h2>
    <p>.fade 和 .show 类用于设置提示框在关闭时的淡出和淡入效果：</p>
    <div class="alert alert-success alert-dismissible fade show">
        <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
        <strong>admin登录权限成功!</strong> 指定操作成功提示信息。
        <a class="btn btn-info" th:href="@{/logout}" th:text="退出系统"></a>
        <form th:action="@{/toLogout}" method="POST">
            <input class="btn btn-info" type="submit" value="注销"/>
        </form>
    </div>
    <div class="alert alert-success alert-dismissible fade show">
        <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
        <strong>登录账号:<span sec:authentication=name>李昊哲</span></strong>
    </div>
    <div class="alert alert-success alert-dismissible fade show">
        <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
        <strong>登录账号:<span sec:authentication=principal.username>李昊哲</span></strong>
    </div>
    <div class="alert alert-success alert-dismissible fade show">
        <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
        <strong>凭证: <span sec:authentication=credentials>李昊哲</span></strong>
    </div>
    <!--
    <div class="alert alert-success alert-dismissible fade show">
        <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
        <strong>权限和角色: <span sec: authentication=authorities>李昊哲</span></strong>
    </div>
    <div class="alert alert-success alert-dismissible fade show">
        <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
        <strong>客户端地址: <span sec: authentication=details.remoteAddress>李昊哲</span></strong>
    </div>
    <div class="alert alert-success alert-dismissible fade show">
        <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
        <strong>sessionId:<span sec: authentication=details.sessionId>李昊哲</span></strong>
    </div>
    -->
    <p>通过角色判断</p>
    <button type="button" class="btn btn-primary" sec:authorize="hasRole('ROLE_user')">insert</button>
    <button type="button" class="btn btn-primary" sec:authorize="hasRole('user')">delete</button>
    <button type="button" class="btn btn-primary" sec:authorize="hasRole('admin')">update</button>
    <button type="button" class="btn btn-primary" sec:authorize="hasAnyRole('admin','user')">select</button>
</div>
</body>
</html>